# Create your views here.
import urllib, urllib2
import os, stat, time, sha, sys
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
import django.utils.simplejson as jsondata
from conf.YoutubeConf import YoutubeConf
from VideoData import VideoData

def render(template, payload):    
    return render_to_response(template, payload)

def index(request):
    vData = VideoData()
    userFavorites = vData.getFavorites()
    userPlaylist = vData.getPlaylist()
    userSubscription = vData.getSubscription()
    payload = dict(favorites = userFavorites, playlist = userPlaylist, subscription = userSubscription)
    return render('videos.html', payload)

def playlistinfo(request,playlist_id):
    vData = VideoData()
    userFavorites = vData.getFavorites()
    userPlaylist = vData.getPlaylist()
    playlistData = vData.getPlaylistInfo(playlist_id)
    
    payload = dict(favorites = userFavorites, playlist = userPlaylist, playlistInfo = playlistData)
    return render('videos-playlist.html', payload)